To support cloud computing, geographically distributed data centers providing data storage are often used. Each data center includes one or more servers at a physical location. Geographically distributed data centers provide fault tolerance capability using data replicas. For example, if one data center is down, the remaining data centers still provide data to users. One risk of replicated data is a lack of consistency. A user should get the same result for a data request regardless of which data center the request is sent to.
Consensus involves multiple servers within a single data center or distributed data centers agreeing on values. Once a consensus decision on a value is reached, that decision is final. To achieve consensus, all instructions that write data must be executed in the same order.
A non-leader-based approach, e.g., Paxos, is one type of algorithm that provides for consensus. In Paxos, a data center that receives a request to write a value first proposes a “prepare” request to all data centers where the value is to be written. Once a majority of data centers respond with a “promise” that the write will be processed, an “accept” request needs to be sent to all of the data centers. Once a majority of data centers accept that the write is complete, a confirmation may be sent to the requester. Thus, two round-trip communications are required between the data centers to achieve consensus in the write.
A leader-based approach, e.g., Raft, is another type of algorithm that provides for consensus. In Raft, a single data center is the leader and all read and write requests are directed to the leader. The remaining data centers are followers. The leader sends each read and write request to the followers and proceeds with a response to the request once a majority of followers have confirmed receipt. Unlike in Paxos, only a single round-trip communication is required to achieve consensus. However, since a single data center is the leader, all client requests must be directed to the leader rather than to the data center nearest to the client.